﻿<Window x:Class="DbDoc.PowerDoc.Views.Settings"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Manage Settings" Height="385" Width="503" ResizeMode="NoResize" ShowInTaskbar="False" Icon="/PowerDoc;component/dbdoc.ico">
    <Grid>
               
        <Grid.RowDefinitions>
            <RowDefinition  Height="35"/>
            <RowDefinition />
            <RowDefinition  Height="35"/>
        </Grid.RowDefinitions>
        <TextBlock Text="  Settings" Grid.Row="0" Style="{StaticResource HeaderText2}" Grid.ColumnSpan="3">
        </TextBlock>
        <TabControl Grid.Row="1" >
            <TabItem Header="General Settings">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="125" />
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition Width="100*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                    </Grid.RowDefinitions>
                                        
                    <TextBlock Grid.Row="1" >Synchronize on Startup</TextBlock>
                    <CheckBox Content="Synchronize on Startup" Grid.Row="1" Grid.Column="1" />
                    <TextBlock Grid.Row="2" >AutoSave</TextBlock>
                    <StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
                    <CheckBox Content="Auto Save" Name="cbAutoSave"  IsChecked="{Binding AutoSave, Mode=TwoWay}" />
                        <TextBlock Margin="5,0,5,0"> every </TextBlock>
                        
                        <TextBox Text="{Binding AutoSaveMinutes}" IsEnabled="{Binding ElementName=cbAutoSave, Path=IsChecked}" Width="30px"></TextBox>
                        <TextBlock  Margin="5,0,5,0"> minutes.</TextBlock>
                    </StackPanel>
                    <TextBlock Grid.Row="3" >Display System Objects</TextBlock>
                    <CheckBox Content="Show me system objects" Grid.Row="3" Grid.Column="1" IsChecked="{Binding DisplaySystemObjects, Mode=TwoWay}" />
                </Grid>
                
            </TabItem>           
            <TabItem Header="Persitence Settings">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="125" />
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition Width="100*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="40" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="1">Providers</TextBlock>
                    <ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding PersistenceProviders}" DisplayMemberPath="Name"  SelectedItem="{Binding SelectedPersistenceProvider}" />
                    <TextBlock Grid.Row="2" >Connection Info</TextBlock>
                    <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding SelectedPersistenceProvider.ConnectionInfo}" TextWrapping="Wrap" ></TextBlock>
                    <TextBlock Grid.Row="3" >Data Store</TextBlock>
                    <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding SelectedPersistenceProvider.StorageName}"></TextBlock>
                   
                </Grid>
            </TabItem>
            <TabItem Header="Admin Settings" IsEnabled="{Binding LoggedUser.IsAdmin, Mode=TwoWay}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="300" />
                        <ColumnDefinition Width="100*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20" />
                        <RowDefinition Height="20*" />
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="1">Require users to login</TextBlock>
                    <CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding EnableUserLogin}" />

                    <TextBlock Grid.Row="2">Synchronize system Objects</TextBlock>
                    <CheckBox  Grid.Row="2" Grid.Column="1" IsChecked="{Binding SynchronizeSystemObjects}" />
                    <TextBlock Grid.Row="4">Existing Users in the system:</TextBlock>
                    <DataGrid AutoGenerateColumns="False" Grid.Column="0" Grid.Row="5" Grid.RowSpan="7" Grid.ColumnSpan="2"
                              ItemsSource="{Binding AppUsers}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Username}" Header="Username" Width="100*" />
                            <DataGridTextColumn Binding="{Binding Password}" Header="Password" Width="100*"/>
                            <DataGridCheckBoxColumn Binding="{Binding IsAdmin}" Header="Is Admin" />
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
        </TabControl>
        <Button Grid.Row="2" Content="Save Settings" Command="{Binding SaveSettingsCommand}"  Width="100"/>
    </Grid>
    
    
</Window>
